﻿package commands 
{
	import flash.utils.ByteArray;
	import commands.classesinfo.*;
	
	/**
	 * ...
	 * @author wwx
	 * 50000002 发底牌
	 */
	public class AssignGroundCardCmd extends abCommand
	{
		
		public function AssignGroundCardCmd() //: abCommand(CommandType.CMD_TYPE_ASSIGNGOUNDCARD) 
		{
			super(CommandType(CommandType.CMD_TYPE_ASSIGNGOUNDCARD));
			cardsInfo = new Array();
		}
		
		public var msgSeq:int;//消息号
		public var errorNum:int;//错误号
		
		public var deskId:int;//桌子id
		public var positionId:int;//桌子位置
		//public var show:int;//是否显示,1：显示,2：隐藏（如果是隐藏，则以下两个数值都为0）

		public var cardsInfo:Array;// CardInfo;
		
		public function convertToCmd(bytes:ByteArray, offset:int, len:int):int
		{
			var ret:int = -1;
			msgSeq = (int) (bytes[offset + 0]) + ((int(bytes[offset + 1])) << 8) + ((int(bytes[offset + 2])) << 16) + ((int(bytes[offset + 3])) << 24);
			offset += 4;
			errorNum = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;
			
			deskId = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;
			positionId = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;
			//show = (int)(bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			//offset += 4;
			 
			var cardInfo:CardInfo = null;
			ret = (int) (bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
			offset += 4;
			
			for (var i:int = 0; i < ret; i++)
			{
				cardInfo = new CardInfo();
				cardInfo.colorOfCard = (int)(bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
				offset += 4;
				cardInfo.contentOfCard = (int)(bytes[offset + 0]) + ((int(bytes[offset+1])) << 8) + ((int(bytes[offset+2])) << 16) + ((int(bytes[offset+3])) << 24);
				offset += 4;
				
				cardsInfo[i] = cardInfo;
			}

			return 0;
		}			
		
	}
	
}